/**
 * 
 */
package org.bf.sms.webservice;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.jws.WebService;

import org.apache.log4j.Logger;
import org.bf.sms.domain.message.Message;


/**
 * 发送短信信息实现
 * 
 * @author LiuChang
 * @version 1.0 2010-12-03
 * @since 1.0
 */
@WebService(endpointInterface = "com.jinye.sms.webservice.SMSServer", serviceName = "SMSServerImpl")
class SMSServerImpl implements SMSServer
{
	/** log4j */
	private static final Logger logger = Logger.getLogger(WebServiceApp.class);

	/** 短信队列 */
	private Map<Integer, Message> messagesMap = new LinkedHashMap<Integer, Message>();

	/**
	 * {@inheritDoc}
	 * 
	 * @see com.jinye.sms.webservice.SMSServer#sendText(String)
	 */
	public String sendText(String text)
	{
		return text; //$NON-NLS-1$
	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see com.jinye.sms.webservice.SMSServer#sendObject(Message)
	 */
	public String sendObject(Message message)
	{
		SMSServerImpl.logger.debug(message);

		this.messagesMap.put(Integer.valueOf(this.messagesMap.size() + 1),
				message);
		return "Hello " + message.getContent(); //$NON-NLS-1$
	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see com.jinye.sms.webservice.SMSServer#sendList(List)
	 */
	public String[] sendList(List<Message> messages)
	{
		SMSServerImpl.logger.debug(messages);

		String[] result = new String[this.messagesMap.size()];
		int i = 0;
		for (Message message : messages) {
			result[i] = "Hello " + message.getContent(); //$NON-NLS-1$
			i++;
		}
		return result;
	}
}